package cart;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.*;
import org.testng.annotations.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class Shipping_tax_empty extends ru.st.selenium.pages.TestBase {
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

    @Test
  public void testUntitled15() throws Exception {
    driver.get(baseUrl + "ottoman.html");
    driver.findElement(By.cssSelector("button.button.btn-cart")).click();
    driver.findElement(By.id("postcode")).clear();
    driver.findElement(By.id("postcode")).sendKeys("");
    driver.findElement(By.cssSelector("#shipping-zip-form > div.buttons-set > button.button")).click();
    try {
      assertEquals("This is a required field.", driver.findElement(By.id("advice-required-entry-postcode")).getText());
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    new Select(driver.findElement(By.id("region_id"))).selectByVisibleText("Please select region, state or province");
    driver.findElement(By.cssSelector("button.button.validation-passed")).click();
    try {
      assertEquals("This is a required field.", driver.findElement(By.id("advice-required-entry-region_id")).getText());
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    driver.findElement(By.linkText("Remove item")).click();
    driver.findElement(By.linkText("here")).click();
  }

   private boolean isElementPresent(By by) {
    try {
      driver.findElement(by);
      return true;
    } catch (NoSuchElementException e) {
      return false;
    }
  }

  
  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      String alertText = alert.getText();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alertText;
    } finally {
      acceptNextAlert = true;
    }
  }
}

